
	<body>
		<div class="layout">
			<!--header-->
			<div class="wrapper">
				<div class="header">
					<a class="s_preson" href="{:U('Index/index')}" > < 首页</a>
					<div class="store">
						<span>订单确认</span>
					</div>
				</div>
			</div>

            <form action="{:U('Order/order')}" method="post" name="buyForm" onsubmit="return judge()">
                <div class="method clearfix">
                    <h2 class="method-title">收货信息<span class="fr"><a href="{:U('Users/address')}">修改地址</a></span></h2>
                    <div class="total">
                        <p><span>收货人：</span>{$address.consignee}<input type="text" value="{$address.consignee}" name="consignee" style="display:none"/></p>
                        <p><span>联系电话：</span>{$address.tel}<input type="text" value="{$address.tel}" name="tel" style="display:none"/></p>
                        <p><span>收货地址：</span>{$address.cityName} \ {$address.zoneName} {$address.address}
                            <input type="text" value="{$address.address}" name="address" style="display:none"/>
                            <input type="text" value="{$address.provinceName}" name="provinceName" style="display:none"/>
                            <input type="text" value="{$address.cityName}" name="cityName" style="display:none" />
                            <input type="text" value="{$address.zoneName}" name="zoneName" style="display:none" />
                        </p>
                    </div>
                </div>

                <ul class="main-content">
                    <h2 class="method-title">产品信息</h2>
                    <volist name="arr" id="co">
                        <!--{$co.goods_id}/{$co.number}-->
                        <input type="text" value="{$co.goods_id}/{$co.number}" name="goods[]" style="display:none"/>
                        <li class="list-item">
                            <div class="list-img"><a href="#"><img src="__UPLOAD__thumb/{$co.thumb}" width="100" alt="" /></a></div>
                            <div class="list-content">
                                <a href="#">
                                    <h3 class="list-title">
                                        {$co.productName}
                                    </h3>
                                </a>
                                <p class="list-price">
                                    <em>{$co.shop_price}</em>&nbsp;
                                    微信支付立减 $<i id="thisPromote{$co.goods_id}">{$co.countPromotePrice}</i>元
                                </p>
                                <!--<div class="list-main">微信支付<span>立减<i>3</i>元</span></div>-->
                                <div class="list-main">价格<span><i id="thisPrice{$co.goods_id}">{$co.price}</i>元</span></div>
                                <div class="list-add"><em class="prev" data="{$co.goods_id}">-</em><input type="text" size="5" value="{$co.number}"/><em class="next" data="{$co.goods.id}">+</em></div>
                            </div>
                        </li>
                    </volist>
                </ul>

                <div class="method clearfix">
                    <h2 class="method-title">付款方式</h2>
                    <ul class="method-way">
                        <li><span>货到付款</span><input type="radio" checked="checked" id="radio-met-1" name="pay_type" class="radio-met" value="0" /><label for="radio-met-1"></label></li>
                        <li><span>微信支付(立减：<em id="promotePrice">{$countPromotePrice}</em>元)</span><input type="radio" id="radio-met-2" name="pay_type" class="radio-met" value="1" /><label for="radio-met-2"></label></li>
                        <hr>
                        <if condition="$sellerID eq 'none'">
                            <li><span>送货上门</span><input type="radio" id="radio-met-4" name="shipping_type" class="radio-met" value="0" disabled="true"/><label for="radio-met-4"></label></li>
                            <span style="color:#ff0000; font-weight:900; font-size:16px;">很抱歉！由于没有任何一家店面在您当前所在位置，所以不能提供“送货上门”,请选择“到店自提”</span>
                        <else />
                            <li><span>送货上门</span><input type="radio" id="radio-met-4" name="shipping_type" class="radio-met" value="0"/><label for="radio-met-4"></label></li>
                            <span style="color:#008200; font-weight:900; font-size:16px;">我们已经为您推送出您当前店面,<font style="color:#000; font-weight:bold;">({$yanG1.nick})</font>将会为您送货</span>
                            <div class="shopInfo">
                                <p>门店名称：<em>{$yanG1.nick}</em></p>
                                <input type="text" value="{$yanG1.id}" name="sellerID" value="{$yanG1.id}" style="display:none;"/>
                            </div>
                        </if>
                            <li><span>门店自提(立减：<em id="ztPrice">{$ztPrice}</em>元)</span><input type="radio" checked="checked" id="radio-met-3" name="shipping_type" class="radio-met" value="1" onclick="showShopInfo()"/><label for="radio-met-3"></label>

                        <if condition="$yanG1[id] neq ''">
                            <div class="shopInfo">
                                <p style="display:none;"><input type="radio" name="sellerID" value="{$yanG1.id}" checked="true"/>选择门店</p>
                                <p><font style="color:red; font-weight: bold;">系统已经为您选出最近的门店</font></p>
                                <p>门店名称：<em>{$yanG1.nick}</em></p>
                                <p>联系人：<em>{$yanG1.linkman}</em></p>
                                <p>联系电话：<em>{$yanG1.tel}</em></p>
                                <p>地址：<em>{$yanG1.address}</em></p>
                                <p>营业时间：<em>早9点至晚9点</em></p>
                            </div>
                        <else />
                        	
                            <volist name="yanG1Arr" id="vo">
                                <div class="shopInfo">
                                    <p><input type="radio" name="sellerID" value="{$vo.id}" id="seller-{$vo.id}" class="radio-met"/>选择门店
                                    <label for="seller-{$vo.id}"></label>
                                    </p>
                                    <p>门店名称：<em>{$vo.nick}</em></p>
                                    <p>联系人：<em>{$vo.linkman}</em></p>
                                    <p>联系电话：<em>{$vo.tel}</em></p>
                                    <p>地址：<em>{$vo.address}</em></p>
                                    <p>营业时间：<em>早9点至晚9点</em></p>
                                </div>
                            </volist>
                        </if>
						</li>
                        <!--<li><span>网银支付</span><input type="radio" id="radio-met-3" name="radio-met" class="radio-met" /><label for="radio-met-3"></label></li>-->
                    </ul>
                    <div class="total">
                        <p>
                            <span>订单总额：</span>
                            <em id="cartPrice">{$countPrice}</em>
                        </p>
                        <input type="text" id="cartPriceInput" name="cartPriceInput" value="{$countPrice}" style="display:none"/>

                        <p>
                            <!--<span>微信立减：</span>-->
                            <!--<em id="promotePrice">{$countPromotePrice}</em>元-->
                            <span>自提立减后总价：</span>
                            <em id="wxPrice">{$ztCountPrice}</em>元
                        </p>
                        <input type="text" id="wxPriceInput" name="wxCountPrice" value="{$wxCountPrice}" style="display:none"/>
                        <input type="text" id="ztPriceInput" name="ztPriceInput" value="{$ztPrice}" style="display:none"/>


                        <!--<p><span>自提立减：</span><em>0</em></p>-->
                        <!--<p><span>使用粮票：</span><em>-5</em></p>-->
                        <!--<p><input type="text" class="addTips" value="输入粮票编码"  /></p>-->
                    </div>
                    <div>
                        <input type="submit" value="去支付" class="settlement"/>
                    </div>
                </div>
            </form>
		</div>
	</body>
</html>

<script type="text/javascript">

function showShopInfo()
{
    var aa = $("#radio-met-3").attr("checked");
    if(aa=="checked")
    {
        $(".shopInfo").show();
    }else{
        $(".shopInfo").hide();
    }
}

function judge()
{

    var one =$("#radio-met-3").attr("checked");
    var two =$("input[name='sellerID']").val();


    if(document.buyForm.consignee.value=="")
    {
        alert("收货人姓名不能为空!");
        document.buyForm.consignee.focus();
        return false;
    }
    else if(document.buyForm.tel.value=="")
    {
        alert("收货联系电话，不能为空!");
        document.buyForm.tel.focus();
        return false;
    }
    else if(document.buyForm.address.value=="")
    {
        alert("收货地址不能为空");
        document.buyForm.address.focus();
        return false;
    }
    else if(document.buyForm.pay_type.value=="")
    {
        alert("请选择支付方式");
        document.buyForm.address.focus();
        return false;
    }
    else if(one=="checked")
    {
        if(two=="")
        {
            alert(two);
            alert("您选择了“到店自提”，请选择具体的店面");
            document.buyForm.address.focus();
            return false;
        }
    }
}

$(function(){
	(function(){
		//表单获取焦点和失去焦点
		var val;
		$('input[type=text]').focus(function(){
			val = $(this).val();
			$(this).val('');
		}).blur(function(){
			$(this).val(val);
		});
		
		//商品加减统计
		var listItem = $('.list-item');
		var listAdd  = listItem.find('.list-add');
		for(var i=0;i<listItem.length;i++){
			fnMain(listItem.eq(i));
		};
				
		function fnMain(quantityCur){
			var oPrev = quantityCur.find('.prev');
			var oNext  =   quantityCur.find('.next');
			var formInput =   quantityCur.find('input');
			
			var num=0;
			
			oPrev.click(function(){
				if(num>0){
					num--;
				};
				formInput.val(num);
                var productID=oPrev.attr("data");
                var number=num;
                $.ajax({
                    url:"{:U('Order/updateNum')}",

                    type: 'POST',

                    data:{
                        productID:productID,
                        number:number
                    },

                    dataType: 'html',

                    timeout: 1000,

//                    error: function(){alert('Error loading PHP document');},

                    success: function(result){
                        var one=result.split("/");
                        $("#cartNum").html(one[0]);
                        $("#cartPrice").html(one[1]);
                        $('#thisPrice'+productID).html(one[2]);
                        $('#thisPromote'+productID).html(one[3]);
                        $('#promotePrice').html(one[4]);
                        var tran=one[1]-one[4];
                        $('#wxPrice').html(tran);
                        $('#cartPriceInput').val(one[1]);
                        $('#wxPriceInput').val(tran);
                    }

                });
			});
			oNext.click(function(){
				num++;
				formInput.val(num);
                var productID=oPrev.attr("data");
                var number=num;
                $.ajax({
                    url:"{:U('Order/updateNum')}",

                    type: 'POST',

                    data:{
                        productID:productID,
                        number:number
                    },

                    dataType: 'html',

                    timeout: 1000,

//                    error: function(){alert('Error loading PHP document');},

                    success: function(result){
                        var one=result.split("/");
                        $("#cartNum").html(one[0]);
                        $("#cartPrice").html(one[1]);
                        $('#thisPrice'+productID).html(one[2]);
                        $('#thisPromote'+productID).html(one[3]);
                        $('#promotePrice').html(one[4]);
                        var tran=one[1]-one[4];
                        $('#wxPrice').html(tran);
                        $('#cartPriceInput').val(one[1]);
                        $('#wxPriceInput').val(tran);
                    }

                });
			});
		};
	})()
});
</script>